<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>个人信息</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">

    <!--标准mui.css-->
    <link rel="stylesheet" href="/public/css/mui.min.css">
    <!--App自定义的css-->
    <link rel="stylesheet" type="text/css" href="/public/css/user.css" />
    <link rel="stylesheet" type="text/css" href="/public/css/app.css" />
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
</head>

<body>
<header class="mui-bar mui-bar-nav">
    <a onclick="dump('<?php echo U('indexSet');?>')" class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
    <script>
        //url跳转
        function dump(url) {
            location.href=url
        }
    </script>
    <h1 class="mui-title">个人信息</h1>
</header>
<div class="mui-content">
    <ul class="mui-table-view">
        <li class="mui-table-view-cell">
            <a id="head" class=""><span class="touxiang">头像</span>
                <span class="mui-pull-right head">
                    <input onchange="updateImage2(this)" type="file" id="fileElem" multiple accept="image/*" style="display: none" >
									<img name="fileSelect" class="head-img mui-action-preview" id="head-img1" src="<?php echo ($data["uProfilePic"]); ?>">
								</span>
            </a>
        </li>
        <li class="mui-table-view-cell">
            <a class="mui-navigate-right">昵称
                <span class="mui-pull-right mr20"><i class="mui-pull-right "></i><input class="nickname" value="<?php echo ($data["uNickName"]); ?>" style="border: 0;text-align: right;" type="text" /></span>
            </a>
        </li>

        <li class="mui-table-view-cell">
            <a class="mui-navigate-right">手机号<span class="mui-pull-right mr20"><i class="mui-pull-right "></i><input class="nickname" value="<?php echo ($data["uMobile"]); ?>" style="border: 0;text-align: right;" type="text" /></span></a>
        </li>
        <li class="mui-table-view-cell">
            <a class="mui-navigate-right">微信号<span class="mui-pull-right mr20"><i class="mui-pull-right "></i></span></a>
        </li>
        <li class="mui-table-view-cell">
            <a class="mui-navigate-right">QQ号<span class="mui-pull-right mr20"><i class="mui-pull-right "></span></a>
        </li>

    </ul>
</div>
</body>

</html>
<script>
    //点击图片调用图片上传
    var fileSelect = document.getElementById("head-img1"),
        fileElem = document.getElementById("fileElem");

    fileSelect.addEventListener("click", function (e) {
        if (fileElem) {
            fileElem.click();
        }
        e.preventDefault(); // prevent navigation to "#"
    }, false);
    //图片预览
    function updateImage2(obj)
    {
        var file = obj.files[0];
        var fileReader = new FileReader();
        fileReader.onloadend = function () {
            if (fileReader.readyState == fileReader.DONE) {
                document.getElementById('head-img1').setAttribute('src', fileReader.result);
            }
        };
        fileReader.readAsDataURL(file);
        var obj = $(obj)
        var fd = new FormData();
        fd.append("upload", 1);
        fd.append("upfile", obj.get(0).files[0]);
        $.ajax({
            url: "<?php echo U('ajaxImg');?>",
            type: "POST",
            processData: false,
            contentType: false,
            data: fd,
            success: function(d) {
                if(d.code != 200)
                {
                    alert(code.msg)
                }
            }
        });
    }
    //昵称修改
    $('.nickname').blur(function () {
        var name = $(this).val()
        $.post("<?php echo U('name');?>",{name:name},function(rel)
        {
            if(rel.code != 200)
            {
                alert(rel.msg)
            }
        })
    })
</script>